<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let persons = [
        { username: "xiaoming1", password: "1111" },
        { username: "xiaoming2", password: "222" },
        { username: "xiaoming3", password: "33333" },
      ];
      //   let user = { username: "admin1", password: "12345" };
      let user = { username: "xiaoming3", password: "33333" };

      let a = persons.find((item) => item.username == user.username);
      if (a) {
        document.write("用户名已注册");
      } else {
        persons.push(user);
        document.write("注册成功");
      }
      console.log(persons);
    </script>
  </body>
</html>
